package primetest.utils;

import java.util.List;

import primetest.dto.BedDto;

public class StringUtils {

	public static String join(String join, Object[] strArray) {
		if (strArray == null) {
			return "";
		}
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < strArray.length; i++) {
			if (i == 0) {
				sb.append(strArray[i]);
			} else {
				sb.append(join).append(strArray[i]);
			}
		}
		return new String(sb);
	}

	public static String join(String join, List<BedDto> strArray) {
		if (strArray == null) {
			return "";
		}
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < strArray.size(); i++) {
			if (i == 0) {
				sb.append(strArray.get(i));
			} else {
				sb.append(join).append(strArray.get(i));
			}
		}
		return new String(sb);
	}

	public static String padding(int index, int length) {
		if (length == -1) {
			return String.valueOf(index);
		} else {
			String str = String.valueOf(index);
			if (str.length() < length) {
				while (str.length() < length) {
					str = "0" + str;
				}
			}
			return str;
		}
	}
}
